<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #parent{
            width: 408px;
            border: 1px solid red;
            margin: 0 auto;
            /* 解决高度为0 */
            overflow: hidden;
        }
        #parent .child{
            width: 100px;
            height: 100px;
            border: 1px dashed #666;
            /* 设置浮动 */
            float: left;
        }
    </style>
</head>
<body>
    <div id="parent">
        <div class="child"></div>
        <div class="child"></div>
        <div class="child"></div>
        <div class="child"></div>
    </div>
</body>
</html>